//
//  XJGoodsDetailFreightRuleCollectionViewCell.m
//  XinJiangMall
//
//  Created by Tzyang on 2018/4/11.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "XJGoodsDetailFreightRuleCollectionViewCell.h"

@interface XJGoodsDetailFreightRuleCollectionViewCell ()

@property (nonatomic ,strong) UILabel * xjgdRuleLab;
@property (nonatomic ,strong) UIButton * xjgdRuleBtn;

@end

@implementation XJGoodsDetailFreightRuleCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = WHITE_COLOR;

        [self setupSubviews];
    }
    return self;
    
}

- (UILabel *)xjgdRuleLab{
    if (!_xjgdRuleLab) {
        UILabel * xjgdRuleLab = [UILabel new];
        self.xjgdRuleLab = xjgdRuleLab;
        [self addSubview:xjgdRuleLab];
    }
    return _xjgdRuleLab;
}


- (UIButton *)xjgdRuleBtn{
    if (!_xjgdRuleBtn) {
        UIButton * xjgdRuleBtn = [UIButton new];
        self.xjgdRuleBtn = xjgdRuleBtn;
        [self addSubview:xjgdRuleBtn];
    }
    return _xjgdRuleBtn;
}

- (void)setupSubviews{
    
    UIView * xjgdLine = [[UIView alloc]initWithFrame:CGRectMake(ADAPTWidth(10), self.frame.size.height-0.5, KWidth - 2*ADAPTWidth(10) , 0.5)];
    xjgdLine.backgroundColor = XJCOLOR_RGB(221, 221, 221);
    [self addSubview:xjgdLine];
    //配送规则
    self.xjgdRuleLab.font = XJFONTSET_R(12);
    self.xjgdRuleLab.textColor = XJCOLOR_RGB(112, 130, 133);
    self.xjgdRuleLab.text = @"运费:￥10起 消费满100免邮";
    CGFloat xjgdRuleLabW = [UILabel labelWithLabel:self.xjgdRuleLab
                                  getWidthWithTitle:self.xjgdRuleLab.text
                                               font:self.xjgdRuleLab.font];
    CGFloat xjgdRuleLabH = [UILabel labelWithLabel:self.xjgdRuleLab
                                   getHeightByWidth:xjgdRuleLabW
                                              title:self.xjgdRuleLab.text
                                               font:self.xjgdRuleLab.font];
    self.xjgdRuleLab.sd_layout
    .leftSpaceToView(self, ADAPTWidth(12))
    .centerYEqualToView(self)
    .widthIs(xjgdRuleLabW)
    .heightIs(xjgdRuleLabH);
    
    
    CGSize xjgdRuleBtnSize = [UIButton getSizeFromButtonTitle:@"查看运费规则" Font:XJFONTSET_R(12)];
    [self.xjgdRuleBtn buttonWithTitle:@"查看运费规则" titleFont:XJFONTSET_R(12) titleColor:XJCOLOR_RGB(112, 130, 133) imageType:ImageTypeImg imageName:@"direction_right_gray" withTarget:nil action:nil style:ImgTextBtnStyleRight margin:15];
    self.xjgdRuleBtn.sd_layout
    .rightSpaceToView(self, ADAPTWidth(15))
    .centerYEqualToView(self)
    .widthIs(xjgdRuleBtnSize.width+20)
    .heightIs(xjgdRuleBtnSize.height);


}

//if (!_xjgdRuleLab) {
//    UILabel
//}

@end
